    <!DOCTYPE html>
    <html >
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <title>EasyLinker</title>
        <meta name="description" content="EasyLinker"/>
        <meta name="keywords" content="EasyLinker"/>
        <meta name="author" content="EasyLinker"/>
        <link rel="icon" type="image/png" href="new_index/favicons/favicon-16x16.png" sizes="16x16"/>
        <link rel="stylesheet" href="new_index/css/bootstrap.css"/>
        <link rel="stylesheet" href="new_index/fonts/font-awesome-4.3.0/css/font-awesome.min.css"/>
        <link rel="stylesheet" href="new_index/css/all.css"/>
        <link href='http://fonts.googleapis.com/css?family=Montserrat:400,700|Source+Sans+Pro:400,700,400italic,700italic' rel='stylesheet' type='text/css'/>
        <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/>
        <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
    </head>
    <style>
        pre{
            background-color: #1f2224;
            color: #FFFFFF;
            margin: auto;
            padding: auto
        }
        li{
            list-style-type:none;
            color: #03a9f3;
            padding: 4px;
            margin: 2px;
        }
    </style>
    <body>
    <div id="wrapper">
        <header id="header">
            <div class="container">
                <div class="logo"><a href="#"><img src="/new_index/images/logo.png" alt="Sports" width="70px"/></a></div>
                <nav id="nav">
                    <div class="opener-holder">
                        <a href="#" class="nav-opener"><span></span></a>
                    </div>

                    <div class="nav-drop">
                        <ul>
                            <li class="active visible-sm visible-xs"><a href="#">Home</a></li>
                            <li><a href="/">首页</a></li>
                            <li><a href="/document">文档</a></li>
                            <li><a href="/loginPage">登录</a></li>
                            <li><a href="/signupPage">注册</a></li>
                        </ul>

                    </div>
                </nav>
            </div>
        </header>
        <section class="visual">
            <div class="container">
                <div class="text-block">
                    <div class="heading-holder">
                        <h1>EasyLinker</h1>
                    </div>
                    <p class="tagline">使用文档</p>
                    <p>项目中会用到一些库，请到相关的网站进行下载</p>
                    <p>以下是SDK开源代码，如果你不需要，可以直接获取SDK包。</p>

                </div>
            </div>
            <img src="new_index/images/img-bg-01.jpg" alt="" class="bg-stretch"/>
        </section>
        <section class="main">
            <div class="container">
                <div id="cta">
                    <a href="javascript:" class="btn btn-primary rounded">开始了解</a>
                </div>
                <div class="row">
                    <div class="text-box col-md-offset-1 col-md-10">
                        <ul style="padding-left: 8px;padding-right:8px;background-color: #2f3638;color: #FFFFFF;text-align: left;width: 100%">
                            <li>Python 客户端接入</li>

                            <pre >
                                <code class="python">
    # -*- coding: utf-8 -*-

    import threading
    import paho.mqtt.client as mqtt

    SERVER_HOST = "47.94.173.41"
    SERVER_PORT = 1883


    class EasyLinkerApp(threading.Thread):
        def on_connect(self, client, userdata, flags, rc):
            print('Device  [%s]  Connected Success!' % self.device_id)
            client.subscribe("device/" + self.device_id)


        def disconnect(self):

            self.mqtt_client.disconnect()
            print('Device  [%s]  Disconnected!' % self.device_id)

        def run(self):
            try:
                # 请根据实际情况改变MQTT代理服务器的IP地址
                self.mqtt_client.connect(SERVER_HOST, SERVER_PORT, 60)
                self.mqtt_client.loop_forever()
            except Exception:
                self.disconnect()

        def __init__(self, device_id, on_message):
            self.device_id = device_id
            self.server_host = SERVER_HOST
            self.server_port = SERVER_PORT
            self.mqtt_client = mqtt.Client()
            self.mqtt_client.on_connect = self.on_connect
            self.mqtt_client.on_message = on_message
            self.mqtt_client.on_disconnect=self.disconnect
            self.mqtt_client.username_pw_set(device_id)
            self.dev_mode = False

        def publish(self, message):
            self.mqtt_client.publish(self.device_id, message)


    # 消息推送回调函数
    def on_message(client, userdata, msg):
        print("receiveed message:" + str(msg.payload))


    app = EasyLinkerApp("e3656586-f7e3-4ad1-9b77-3a8c68f25e39", on_message)
    app.run()
    app.publish("hello")
                                </code>
                            </pre>
                            <li>Ardiuno客户端接入</li>
                            <pre>
                                <code>
#include &lt;SPI.h>
#include &lt;Ethernet.h>
#include &lt;PubSubClient.h>
byte mac[]    = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress server(192, 168, 199, 107);
EthernetClient ethClient;
PubSubClient client(ethClient);
int LED_GPIO = 5;
String deviceId="c56ff6d3-541d-4862-b3db-a26f44c921d2";
String topic="device";
char * id="device/c56ff6d3-541d-4862-b3db-a26f44c921d2";
void onMessageReceived(char* topic, byte* payload, unsigned int length) {
  String message = "";
  for (int i = 0; i < length; i++) {
    message += (char)payload[i];
  }
   Serial.println(message);

  if (message == "ON") {
    digitalWrite(LED_GPIO, HIGH);
  } else if (message == "OFF") {
    digitalWrite(LED_GPIO, LOW);
  }

}


void reconnect() {
  while (!client.connected()) {
    Serial.println("Connection interrupted!Attempting MQTT resume...");
    if (client.connect("arduinoClient-c56ff6d3-541d-4862-b3db-a26f44c921d2")) {
      client.subscribe("device/c56ff6d3-541d-4862-b3db-a26f44c921d2");
    } else {
      delay(2000);
    }
  }
}

void setup()
{
  Serial.begin(57600);
  pinMode(LED_GPIO, OUTPUT);
  Serial.println("Start device...");
  client.setServer(server, 1883);
  client.setCallback(onMessageReceived);
  Ethernet.begin(mac);
  client.connect("arduinoClient-c56ff6d3-541d-4862-b3db-a26f44c921d2");
  client.subscribe("device/c56ff6d3-541d-4862-b3db-a26f44c921d2");
  Serial.println("Start device finished.");
  delay(1500);
}

void loop()
{
  if (!client.connected()) {
    reconnect();
  }
  client.loop();
}

                                </code>
                            </pre>
                            <li>Java客户端接入</li>
                            <pre>
                                <code>

                                </code>
                            </pre>
                            <li>C++客户端接入(windows demo)</li>
                            <pre>
                                <code>
#include "stdafx.h"
#include "mosquitto.h"
#include "mosquittopp.h"
#include &lt;iostream>
#include &lt;string>
using namespace std;
/*
virtual void on_connect(int rc) {return;};
virtual void on_disconnect(int rc) {return;};
virtual void on_publish(int mid) {return;};
virtual void on_message(const struct mosquitto_message *message) {return;};
virtual void on_subscribe(int mid, int qos_count, const int *granted_qos) {return;};
virtual void on_unsubscribe(int mid) {return;};
virtual void on_log(int level, const char *str) {return;};
virtual void on_error() {return;};
*/
class MQttClient :public mosqpp::mosquittopp {
public:
	int mid = 1;
	MQttClient(const char* id) :mosquittopp(id) {
		std::cout << "MQttClient:[" << id << "]" << endl;
	}
	void on_connect(int rc) {
		this->subscribe(&mid, "device");

		std::cout << "MQttClient  connected success with rc :" << rc << endl;
	};
	void on_subscribe(int mid, int qos_count, const int *granted_qos) {
		std::cout << "MQttClient  subscribe success" << endl;
	};
	void on_message(const struct mosquitto_message *message) {

		std::string receiveMessage = (char *)message->payload;
		std::cout << "来自<" << message->topic << ">的消息：" << receiveMessage << std::endl;
	};
	void on_disconnect() {
		std::cout << "MQttClient  disconnect!" << endl;
	};
	void on_error() {
		std::cout << "MQttClient  error" << endl;
	}
};
int main(int argc, char** argv)
{
	mosqpp::lib_init();
	MQttClient client("client");

	client.connect("127.0.0.1", 1884);
	client.loop_forever(100);
	system("pause");
	return 0;
}

                                </code>
                            </pre>

                        </ul>

                    </div>
                </div>
            </div>
        </section>


        <footer id="footer" style="background-color:black;">
            <div class="container">
                <div class="footer-holder">
                    <div class="row  text-center">
                        <div class="col-md-12">
                            <a href="#"><img src="new_index/images/logo.png" alt="Sports HTML Template"/></a>
                        </div>

                    </div>
                    <div class="row">
                        <div id="cta" class="cta-footer">
                            <a href="javascript:" class="btn btn-primary rounded">关注开源</a>
                            <p>积极参加开源，为项目贡献力量，让更多人学习项目。</p>
                            <a href="https://github.com/wwhai/easylinker ">https://github.com/wwhai/easylinker</a>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <h3>关于我们</h3>


                            <p>	@EasyLinker Team</p>
                            <p>	Email:751957846@qq.com</p>
                            <p>	QQ群:475512169</p>

                        </div>

                    </div>
                </div>
            </div>
        </footer>
    </div>
    <script src="new_index/js/jquery-1.11.2.min.js"></script>
    <script src="new_index/js/bootstrap.js"></script>
    <script src="new_index/js/jquery.main.js"></script>
    </body>
    </html>